<?php

class McCube_Html_Menu extends McCube_Html_Abstact{

    protected $_title = '';
    protected $_items = array();
    protected $_itemsSeparator = '';

    public function __construct(){

    }

    public function __toString(){
        return $this->render();
    }

    public function title($title){
        $this->_title = $title;
        return $this;
    }

    public function items($items){
        $this->_items = $items;
        return $this;
    }

    public function separator($separator){
        $this->_itemsSeparator = $separator;
        return $this;
    }

    protected function _buildTitle(){
        if($this->_title)
            return '<h5>'.$this->_title.'</h3>';
    }

    protected function _buildItems(){
        foreach($this->_items as $href => $txt)
            $echo[] = '<li><a href="'.$href.'">'.$txt.'</a></li>';

        return implode($this->_itemsSeparator, $echo);
    }

    public function render(){
        return
            '<ul '.parent::buildAttrs().' class="menu">'
                .$this->_buildTitle()
                .$this->_buildItems()
            .'</ul>'
        ;
    }

}